package com.xqx.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xqx.mapper.StudentMapper;
import com.xqx.pojo.Student;
import com.xqx.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author：xingquanxiang createTime：2019/10/26 15:17
 * description:
 */
@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public PageInfo<Student> findAll(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return new PageInfo<Student>(studentMapper.findAll());
    }

    @Override
    public Student doAdd(Student student) {
        studentMapper.add(student);
        return student.getId()!=null ? student : null;
    }

    @Override
    public boolean doEdit(Student student) {
        return studentMapper.edit(student)==1;
    }

    @Override
    public int doDel(long[] id) {
        return studentMapper.del(id);
    }

    @Override
    public Student findById(long id) {
        return studentMapper.findById(id);
    }

    @Override
    public boolean findByNameAndPassword(Student student) {
        return studentMapper.findByNameAndPassword(student)!=null;
    }
}
